public class Leetcode_3 {
    public static boolean isPalindrome(int x) {
        if (x < 0 || (x % 10 == 0 && x != 0)) {
            return false;
        }

        int revertedNumber = 0;
        while (x > revertedNumber) {//121
            //0=0*10+121%10==1
            //1=1*10+12%10==12
            revertedNumber = revertedNumber * 10 + x % 10;
            //x= 121 / 10==12
            //x= 12 / 10==1
            x /= 10;
        }
        //x=1
        //x=12||x==12/10
        return x == revertedNumber || x == revertedNumber / 10;
    }
    public static void main(String... args) {
        int x = 121;
        System.out.println(isPalindrome(x));
    }
}
